<?php

class Authentification extends CI_Controller
{
	
	public function authentifier($etat)
	{
		$this->load->helper('url');

		$this->session->userdata('matricule');

		if (($this->session->userdata('matricule')== FALSE))
			{	
				if($etat == "accueil")
				{
					// Chargement du helper form et affichage des vues souhaitees
					$this->load->helper('form');
					$this->load->view('header.php');
					$this->load->view('v_authentification.php');
					$this->load->view('footer.php');
				}
				else
				{
				if($etat == "controle")
					{
						// chargement du mod�le
						$this->load->model('modeleAuthentification');
						$req = $this->modeleAuthentification->controleAuthentification();
						if ($req == TRUE)
						{
							$this->session->set_userdata('matricule', $req['matricule']);
							$this->session->set_userdata('admin', $req['admin']);
							// Affichage des vues headerAdmin,  accueilAdmin et footerAdmin
							if ($this->session->userdata('admin')== FALSE)
							{	
								$this->load->view('headerClient.php');
								$this->load->view('v_accueilClient.php');
							}
							else
							{
								$this->load->view('headerAdmin.php');
								$this->load->view('v_accueilAdmin.php');
							}
							
						}
						else
						{
							// Chargement du helper form et affichage des vues souhaitees
							$this->load->helper('form');
							$this->load->view('header.php');
							// Affichage de la vue v_authentification (avec passage d'un message ?)
							$this->load->view('v_authentification.php');
							$this->load->view('footer.php');
						}
					}
				}
			}
		else
			{
				if ($this->session->userdata('admin')== FALSE)
					{	
						$this->load->view('headerClient.php');
						$this->load->view('v_connecte.php');
						$this->load->view('footer.php');
					}
				else
					{
						$this->load->view('headerAdmin.php');
						$this->load->view('v_connecte.php');
						$this->load->view('footer.php');
					}
					
			}
	}
	public function deconnexion()
						{	
							if (($this->session->userdata('matricule')== TRUE))
							{	
								$this->load->helper('url');
								$this->session->sess_destroy();
								$this->load->view('header.php');
								$this->load->view('v_presentation.php');
								$this->load->view('footer.php');
							}
							else
							{
								$this->load->helper('url');
								$this->load->view('header.php');
								$this->load->view('v_interdiction.php');
								$this->load->view('footer.php');
							}
						}
}
/* End of file Authentification.php */
/* Location: ./application/controllers/authentification.php */
?>